<?php
/*
usage:
php xp_project_console_package_h5publish.php csmitsm
*/
include "xp_project_function.php";

$pluginname = $argv[1]; 
$root = __DIR__;

if(true){
    $srcpath = "{$root}/addons/{$pluginname}/uniapp/{$pluginname}_xcflow_xcform";
    $distpath = "{$root}/public/assets/addons/{$pluginname}/h5_xcflow_xcform";
    if (file_exists($srcpath)) {
        chdir($srcpath);
        //shell_exec("npx update-browserslist-db@latest");
        shell_exec("npm run build");
        deleteDirectory($distpath);
        mkdir($distpath);
        xcopy("{$srcpath}/dist", $distpath);
    }
}

if(false){
    $srcpath = "{$root}/addons/{$pluginname}/uniapp/{$pluginname}_pc_console";
    $distpath = "{$root}/public/assets/addons/{$pluginname}/h5_pc_console";
    if (file_exists($srcpath)) {
        chdir($srcpath);
        shell_exec("cli publish --platform H5 --project {$pluginname}_pc_console");
        deleteDirectory($distpath);
        mkdir($distpath);
        xcopy("{$srcpath}/unpackage/dist/build/web", $distpath);
    }
}

if(false){
    $srcpath = "{$root}/addons/{$pluginname}/uniapp/{$pluginname}_mobile";
    $distpath = "{$root}/public/assets/addons/{$pluginname}/h5";
    if (file_exists($srcpath)) {
        chdir($srcpath);
        echo "cli publish --platform H5 --project {$pluginname}_mobile";
        deleteDirectory($distpath);
        mkdir($distpath);
        xcopy("{$srcpath}/unpackage/dist/build/web", $distpath);
    }
}
 